////<!--异常进场-->

export default {
    data() {
        return {
            bigImgPath: '',
            vipType: {
                name: '',
                value: '',
            },
            typeInfo: [],
            bindingCarCodeList: [],
            abnormalInCarExceptionTypeDetail: {}, //同车场再次进场的记录obj
        }
    },
    created() {
        this.getTypeList({});
    },
    methods: {
        // 进场记录详情
        detailRecord(rowData) {
            let self = this
            self.abnormalInCarExceptionTypeDetail = rowData.abnormalInCarExceptionTypeDetail
            self.toOpenModal('inCarExceptionTypeDetailModal')
        },
        // 查看已绑定的车牌号
        checkBindingCarCode(row, modalName) {
            let self = this
            self.bindingCarCodeList = []
            let params = {
                logicCardCode: row.carCode
            }
            API.fetchGet('monthTicketBill/getLogicCardCodeDetail', params).then(res => {
                if (res.data) {
                    let data = res.data
                    let obj = {
                        carCode: data.logicCardCode, //车牌
                    }
                    if (data.openid) { //微信
                        obj.cardCode = data.nickname //备注卡号
                    } else {
                        obj.cardCode = data.cardCode //备注卡号
                    }
                    self.bindingCarCodeList.push(obj)
                }
                self.toOpenModal(modalName)
            }, err => {})
        },
        getList() {
            let params = $.extend({}, this.searchParams, this.otherParams);
            if (!params.parkIds) {
                this.showToast('请先选择停车场!', 0)
                return
            }
            if (params.hasOwnProperty("carCode")) {
                delete params.carCode
                let attribStr = this.searchList[1].value
                params[attribStr] = this.searchList[1].inputVal
            }
            if (params) {
                for (let key in params) {
                    if (params[key] === "" || params[key] === null) {
                        delete params[key]
                    }
                }
            }
            this.getItemList(params);
        },
        showBigImgModal(name, path) {
            this.bigImgPath = path;
            this.toOpenImgModal(name, path);
        },
        //获取列表
        getItemList(aparams) {
            let self = this,
                params = {
                    page: this.pageNumber,
                    rp: this.pageSize
                };
            params = $.extend({}, params, aparams);
            API.fetchGet('/park/abnormalInCar/getAbnormalInCar.do', params)
                .then(res => {
                    let data = res.data,
                        list = data.rows;
                    self.tbodysInfo = list;
                    self.total = data.total;
                }, err => {})
        },

        //获取vip类型列表
        getTypeList(aparams) {
            let self = this,
                params = {};
            var tep = [];
            self.typeInfo = [];
            params = $.extend({}, params, aparams);
            API.fetchGet('/park/abnormalOutCar/typeList.do', params)
                .then(res => {
                    let data = res.data;
                    tep = data;
                    var option = {
                        name: '',
                        value: null,
                    };
                    option['name'] = '全部';
                    option['value'] = '';
                    self.typeInfo.push(option);
                    var option2 = {
                        name: '',
                        value: null,
                    };
                    option2['name'] = '临时车';
                    option2['value'] = 'temp_car';
                    self.typeInfo.push(option2);
                    for (var i = 0; i < tep.length; i++) {
                        var option1 = {
                            name: '',
                            value: null,
                        };
                        var name = tep[i].vipName;
                        var value = tep[i].id;
                        option1['name'] = name;
                        option1['value'] = value;
                        self.typeInfo.push(option1);
                    }
                    self.initVIPTypeSearch()
                }, err => {});

        },
        initVIPTypeSearch() {
            let self = this;
            self.searchList[2].options = self.typeInfo;
        },
        exportData() {
            let self = this;
            let theadsArr = []
            for (let i = 0; i < self.theadsInfo.length; i++) {
                if (self.theadsInfo[i].checked) {
                    theadsArr.push(self.theadsInfo[i].prop)
                }
            }
            let params = {
                meterList: theadsArr.join(',')
            };
            params = $.extend({}, params, this.searchParams, this.otherParams);
            if (params.hasOwnProperty("carCode")) {
                delete params.carCode
                let attribStr = this.searchList[1].value
                params[attribStr] = this.searchList[1].inputVal
            }
            for (let key in params) {
                if (params.hasOwnProperty(key)) {
                    if (params[key] !== 0 && !params[key]) {
                        delete params[key]
                    }
                }
            }
            self.showDialog("确认导出该报表?", '', function () {
                self.toExportAsync('park/abnormalInCar/exportAbnormalInCar.do', params)
            })

        },
        // 处理访问不了的图片
        handleImg(e, rowObj) {
            if (e.target.className == 'carNoImageUrl') { //小图
                rowObj.carNoImageUrl = null
            } else if (e.target.className == 'carImageUrl') { //大图
                rowObj.carImageUrl = null
            }
        },
    }
}